<?php
namespace Admin\Controller;
use Think\Controller;
header('content-type:text/html;charset=utf-8');
class IndexApiController extends Controller{
	/**
	 * 首页对应的一些接口
	 */
	function __construct() {
		parent::__construct();
		$host = $_SERVER['HTTP_HOST'];
		$URI = $_SERVER['PHP_SELF'];
		$xiangmu = split("/", $URI);
		$xiangmu = $xiangmu[1];
		$img_url = 'http://' . $host . '/' . $xiangmu . "/";
		
	}
	
	//接受参数接口
	public function Receicer() {
		$a = file_get_contents('php://input');
		$b = json_decode($a, true);
		if (!empty($_POST)) {
			return $_POST;
		} elseif (!empty($b)) {
			return $b;
		} else {
			echo json_encode(array('result' => '0', 'message' => '请提交参数'));
			exit;
		}
	}
	
	/**
	 * 查询轮播图信息
	 */
	public function banner(){
		$model=M("news");
		$cond=array("cover"=>2);
		$data=$model->where($cond)->field("id,img")->limit(5)->select();
		if($data){
			
			echo json_encode(array("result"=>1,"data"=>$data));
			exit;
		}else{
			echo json_encode(array("result"=>0,'message'=>'查询结果为空'));
		}
	}
	/**
	 * 查询所有新闻信息
	 */
	public function news(){
		
	}
	/**
	 * 查询指定新闻信息
	 */
	public function news_one(){
		
	}
	
}